const { resolve } = require('../../helper')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = function(title = '', fileName, inject, vhost){
	const { dev } = this.command
	const { template } = this.appConf
	const minify = dev ? Object.create(null) : {
		collapseWhitespace: true,
		removeAttributeQuotes: true,
		minifyJS: true, minifyCSS: true
	}
	return new HtmlWebpackPlugin({
		title, minify, chunks: ['vendor','manifest', fileName],
		chunksSortMode: 'manual', template: resolve(template),
		filename: `${fileName}.html`, injectJS: inject.injectJS, injectCSS: inject.injectCSS,
		vhost
	})
}